package banwood.com.xiongfasy.BASE;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by Administrator on 2017/5/24 0024.
 */

public class GetMessage {

    public static String getVersion(Context context){
        try {
            PackageManager manager=context.getPackageManager();
            PackageInfo info=manager.getPackageInfo(context.getPackageName(),0);
            String version=info.versionName;
            return "V"+version;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return "版本号异常";
        }
    }

    //获取当前日期：年-月-日
    public static String getData(){
        long time=System.currentTimeMillis();
        SimpleDateFormat format=new SimpleDateFormat("yyyy/MM/dd");
        Date d1=new Date(time);
        String data=format.format(d1);
        return data;
    }

    //获取时间
    public static String getSystemTime(){
        long time=System.currentTimeMillis();
        SimpleDateFormat format=new SimpleDateFormat("yyyyMMddHHmmss");
        Date d1=new Date(time);
        String data=format.format(d1);
        return data;
    }

    //获取当前的时间
    public static String getTime(){
        long time=System.currentTimeMillis();
        SimpleDateFormat format=new SimpleDateFormat("HH:mm:ss");
        Date d1=new Date(time);
        String data=format.format(d1);
        return data;
    }
}
